package com.example.demo03_mvm.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.demo03_mvm.R;
import com.example.demo03_mvm.databinding.ItemCartBinding;
import com.example.demo03_mvm.databinding.ItemLeftBinding;
import com.example.demo03_mvm.databinding.ItemRightBinding;
import com.example.demo03_mvm.db.KfEntity;
import com.example.demo03_mvm.model.CartEntity;

import java.util.List;

public class KfAdapter extends BaseMultiItemQuickAdapter<KfEntity, BaseViewHolder> {
    public KfAdapter() {
        addItemType(0, R.layout.item_left);
        addItemType(1, R.layout.item_right);
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
        DataBindingUtil.bind(holder.itemView);
        super.onBindViewHolder(holder, position);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, KfEntity dataBean) {
        if(dataBean.getWho()==0) {
            ItemLeftBinding binding = (ItemLeftBinding) DataBindingUtil.getBinding(baseViewHolder.itemView);
            binding.setLeft(dataBean);
        }else{
            ItemRightBinding binding = (ItemRightBinding) DataBindingUtil.getBinding(baseViewHolder.itemView);
            binding.setRight(dataBean);
        }
    }
}
